<?php
use yii\helpers\Html;
use yii\helpers\Url;
use app\lib\WeixinUtils;

/* @var $this yii\web\View */
/* @var $content string 字符串 */


$web = Url::to("@web");

?>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <title>发票信息</title>
    <link type="text/css" href="<?=$web?>/css/home/invoice_form.css" rel="stylesheet"/>
    <link type="text/css" href="<?=$web?>/css/home/global.css" rel="stylesheet"/>
    <style type="text/css">
        .RadioLabelClass{
            background:url(<?=$web?>/img/home/invoice_form_image/di_w.png) no-repeat;
            -webkit-background-size: 1.4em 1.4em;
        }
        .RadioSelected{
            background:url(<?=$web?>/img/home/invoice_form_image/di_y.png) no-repeat;
            -webkit-background-size: 1.4em 1.4em;
        }
        .haeder_imag{
            background-image: url("<?=$web?>/img/home/invoice_form_image/invoiceme_hander.png");
        }
    </style>
    <script type="text/javascript" src="<?=$web?>/js/jquery.js"></script>
    <script type="text/javascript" src="<?=$web?>/js/tools.js"></script>
    <script type="text/javascript">
        $(function() {
            // 任何需要执行的js特效
            var w = $(document).width();
            if (w > 640) {
                w = 640;
            }
            $("body").css("font-size", w * 20 / 320);
        });

        $(document).ready(function (){
            $('#type_type_right').click(function (){
                DTYPE=2;
                $(".header").css({"display":"none"});
                $(".content").css({"display":"none"});
                $(".address").css({"display":"none"});
                //$(".but").css({"display":"none"});
                $(".text").show();
                $(".type_type_left").css({"background-image":"url(<?=$web?>/img/home/invoice_form_image/invoiceme_type_left_w.png)","-webkit-background-size":"100%"});
                $(".type_type_right").css({"background-image":"url(<?=$web?>/img/home/invoice_form_image/invoiceme_type_right_y.png)","-webkit-background-size":"100%"});
                $(".type_type_right1").css({"background-image":"url(<?=$web?>/img/home/invoice_form_image/invoiceme_type_right1.png)","-webkit-background-size":"100%"});
            });

            $('#type_type_left').click(function (){
                DTYPE=1;
                $(".header").css({"display":""});
                $(".content").css({"display":""});
                $(".address").css({"display":""});
                $(".but").css({"display":""});
                $(".text").hide();
                $(".type_type_left").css({"background-image":"url(<?=$web?>/img/home/invoice_form_image/invoiceme_type_left.png)","-webkit-background-size":"100%"});
                $(".type_type_right").css({"background-image":"url(<?=$web?>/img/home/invoice_form_image/invoiceme_type_right.png)","-webkit-background-size":"100%"});
                $(".type_type_right1").css({"background-image":"url(<?=$web?>/img/home/invoice_form_image/invoiceme_type_right1.png)","-webkit-background-size":"100%"});
            });
            $('#type_type_right1').click(function (){
                DTYPE=0;
                $(".text").hide();
                $(".header").css({"display":"none"});
                $(".content").css({"display":"none"});
                $(".address").css({"display":"none"});
                $(".type_type_left").css({"background-image":"url(<?=$web?>/img/home/invoice_form_image/invoiceme_type_left_w.png)","-webkit-background-size":"100%"});
                $(".type_type_right").css({"background-image":"url(<?=$web?>/img/home/invoice_form_image/invoiceme_type_right.png)","-webkit-background-size":"100%"});
                $(".type_type_right1").css({"background-image":"url(<?=$web?>/img/home/invoice_form_image/invoiceme_type_right1_y.png)","-webkit-background-size":"100%"});
            });
        });




        $(document).ready(function(){


            $(".RadioClass").change(function(){
                if($(this).is(":checked")){
                    $(".RadioSelected:not(:checked)").removeClass("RadioSelected");
                    $(this).next("label").addClass("RadioSelected");
                }
            });
        });
        var DTYPE=-1;
        $(function($){
            //没有发票信息的时候--初始化
            $('#type_type_left').click();
            $(".RadioSelected:not(:checked)").removeClass("RadioSelected");
            $("input:radio[name='invoice_content_type']:eq(0)").prop("checked",true).next("label").addClass("RadioSelected");
            //有发票信息的时候
        });
        function invoice_submit(){


            var DCONTENT_TYPE=$("input:radio[name='invoice_content_type']:checked").val();
            var data={};
            data.object_type="<?=$object_type?>";
            data.object_id="<?=$object_id?>";
            data.DTYPE=DTYPE;
            data.DINVOICE_TITLE=$('.input_title').val();
            data.DRECEIVER_NAME=$('.input_name').val();
            data.DRECEIVER_PHONE=$('.input_phone').val();
            data.DRECEIVER_ADDRESS=$('.input_address').val();
            data.DREMARK="";
            data.DFREIGHT=8;
            data.DCONTENT_TYPE=DTYPE==1?DCONTENT_TYPE:-1;
            if(DTYPE==1){
                if(data.DINVOICE_TITLE._trim()==''){
                    alert('必须填写发票抬头');
                    return;
                }
                if(data.DRECEIVER_ADDRESS._trim()==''){
                    alert('必须填写收件人地址');
                    return;
                }
                if(data.DRECEIVER_NAME._trim()==''){
                    alert('必须填写收件人姓名');
                    return;
                }
                if(checkMobile(data.DRECEIVER_PHONE._trim())==false){
                    alert('必须填写正确的收件人手机');
                    return;
                }
            }

            var re=returnjson('<?=Url::to(['wx-home/submit-invoice-handle'])?>',data);
            if (re.flag == 0) {
                alert(re.msg);
                return;
            } else {
                alert('ok');
            }
        }
    </script>
</head>
<body>

<div class="main">
    <div class="type">
        <div class="type_text">发票类型</div>
        <div class="type_type">
            <div id="type_type_left" class="type_type_left" style="background-image: url('<?=$web?>/img/home/invoice_form_image/invoiceme_type_left.png')"></div>
            <div id="type_type_right" class="type_type_right" style="background-image: url('<?=$web?>/img/home/invoice_form_image/invoiceme_type_right.png')"></div>
            <div id="type_type_right1" class="type_type_right1" style="background-image: url('<?=$web?>/img/home/invoice_form_image/invoiceme_type_right1.png')"></div>
        </div>
    </div>
    <div class="header">
        <div class="type_text">发票抬头</div>
       <div style="margin-left: 1em">
           <input class="input_title" type="text" placeholder="公司名称"/>
       </div>
    </div>
    <div class="content">
        <div class="content_text">发票内容</div>
        <?php
            $i=0;
            foreach($invoice_content_types as &$invoice_content_type ){
                $i++;
                ?>
                <div class="electric">
                    <input id="Radio<?=$i?>" type="radio" class="RadioClass" name="invoice_content_type" value="<?=$invoice_content_type['CODE']?>"/>
                    <label id="Label<?=$i?>" for="Radio<?=$i?>" class="RadioLabelClass"></label>
                    <label style="margin-left:-2.5em;"><?=$invoice_content_type['REMARK']?></label>
                </div>
                <?php
            }
        ?>
        <!--<div class="electric">
            <input id="Radio1" type="radio" class="RadioClass" name="group1">
            <label id="Label1" for="Radio1" class="RadioLabelClass"></label>
            <label style="margin-left:-2.5em;">数码电脑配件</label>
        </div>-->


    </div>
    <div class="address">
        <div class="address_text">
            发票接收地址
        </div>
        <div class="electric">
            <input class="input_address" type="text" placeholder="地址"/>
        </div>
        <div class="electric">
            <input class="input_name" type="text" placeholder="姓名"/>
        </div>
        <div class="electrics">
            <input class="input_phone" type="text" placeholder="手机" maxlength="11"/>
        </div>
    </div>
    <div class="text">如需增值税发票请联系  400-860-3111</div>
    <div class="but" onclick="invoice_submit()">确认提交</div>

</div>

</body>
</html>
